package com.ship.control.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.ship.control.AbstractAdminCommandController;
import com.ship.control.search.SearchStat;
import com.ship.control.search.ShipMaterialSearchCond;
import com.ship.entity.ShipLog;
import com.ship.entity.ShipMaterial;
import com.ship.service.ShipService;

/**
 * 物料清单管理
 * @author wqf
 * @version  Nov 24, 2011 12:00:53 PM
 */
public class ShipMaterialListController extends AbstractAdminCommandController {

	public ShipMaterialListController(){
		this.setCommandClass(ShipMaterialSearchCond.class);
	}
	
	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
		throws Exception{
		
		ShipMaterialSearchCond shipMaterialSearchCond=(ShipMaterialSearchCond)command;
						
		ModelAndView mav=new ModelAndView(this.view);
		shipMaterialSearchCond.setPageSize(10L);
						
		SearchStat searchStat=this.shipService.getSearchStat(ShipMaterial.class, shipMaterialSearchCond);
		List<ShipMaterial> shipMaterialList=this.shipService.getShipMaterialList(shipMaterialSearchCond);
		mav.addObject("searchStat", searchStat);
		mav.addObject("shipMaterialList", shipMaterialList);
		mav.addObject("shipMaterialSearchCond", shipMaterialSearchCond);
		
		return mav;
		
	}
	
	public void setShipService(ShipService shipService) {
		this.shipService = shipService;
	}

	private String view;
	private ShipService shipService;
	
	public void setView(String view) {
		this.view = view;
	}

}
